home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / chisqr_pdf.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  61 lines

  1. ;$Id: chisqr_pdf.pro,v 1.3 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1994-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5. ;+
  6. ; NAME:
  7. ;       CHISQR_PDF
  8. ;
  9. ; PURPOSE: 
  10. ;       This function computes the probabilty (p) such that:
  11. ;                   Probability(X <= v) = p
  12. ;       where X is a random variable from the Chi-square distribution
  13. ;       with (df) degrees of freedom.
  14. ;
  15. ; CATEGORY:
  16. ;       Statistics.
  17. ;
  18. ; CALLING SEQUENCE:
  19. ;       Result = chisqr_pdf(V, DF)
  20. ;
  21. ; INPUTS:
  22. ;       V:    A scalar of type integer, float or double that specifies 
  23. ;             the cutoff value.
  24. ;
  25. ;      DF:    A positive scalar of type integer, float or double that
  26. ;             specifies the degrees of freedom of the Chi-square distribution.
  27. ;
  28. ; EXAMPLES:
  29. ;       Compute the probability that a random variable X, from the Chi-square 
  30. ;       distribution with (DF = 3) degrees of freedom, is less than or equal 
  31. ;       to 6.25. The result should be 0.899939 
  32. ;         result = chisqr_pdf(6.25, 3)
  33. ;
  34. ;       Compute the probability that a random variable X, from the Chi-square
  35. ;       distribution with (DF = 3) degrees of freedom, is greater than 6.25. 
  36. ;       The result should be 0.100061
  37. ;         result = 1 - chisqr_pdf(6.25, 3)
  38. ;
  39. ; REFERENCE:
  40. ;       ADVANCED ENGINEERING MATHEMATICS (seventh edition)
  41. ;       Erwin Kreyszig
  42. ;       ISBN 0-471-55380-8
  43. ;
  44. ; MODIFICATION HISTORY:
  45. ;       Modified by:  GGS, RSI, July 1994
  46. ;                     Minor changes to code. New documentation header.
  47. ;-
  48.  
  49. function chisqr_pdf, x, df
  50.  
  51.   on_error, 2  ;Return to caller if error occurs.
  52.  
  53.   if x le 0 then return, 0.0 else begin
  54.     gres = igamma_pdf(df/2.0, x/2.0)
  55.     if gres ne -1 then return, gres else $
  56.       message, 'Computational error detected.'
  57.   end
  58.  
  59. end
  60.  
  61.